<html>
<head><meta charset="utf-8"><title>Which kind of operands functions are? · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html">Which kind of operands functions are?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160837661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160837661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160837661">(Mar 15 2019 at 00:59)</a>:</h4>
<p>I'm trying to follow the execution of a function from a call terminator on MIR (<a href="https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc_mir/interpret/terminator.rs#L77" target="_blank" title="https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc_mir/interpret/terminator.rs#L77">https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc_mir/interpret/terminator.rs#L77</a>) and I wanted to know which kind of operands (<a href="https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc/mir/mod.rs#L2113" target="_blank" title="https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc/mir/mod.rs#L2113">https://github.com/rust-lang/rust/blob/f058741a679062202697144daebd05e1b0d6d747/src/librustc/mir/mod.rs#L2113</a>) functions are</p>



<a name="160838830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160838830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160838830">(Mar 15 2019 at 01:22)</a>:</h4>
<p>I assume functions declared with <code>fn () {...}</code> are just constants?</p>



<a name="160853103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160853103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160853103">(Mar 15 2019 at 07:29)</a>:</h4>
<p>Yes</p>



<a name="160880689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160880689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160880689">(Mar 15 2019 at 14:38)</a>:</h4>
<p>On which stage rustc stores functions to be called later?</p>



<a name="160880767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160880767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160880767">(Mar 15 2019 at 14:39)</a>:</h4>
<p>What do you mean by "stores functions"?</p>



<a name="160881487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160881487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160881487">(Mar 15 2019 at 14:47)</a>:</h4>
<p>Well right now I understand that in order to evaluate a function, const-eval adds a new frame to the stack with a reference to the MIR of the function. Where are the representations of functions stored to be retrieved?</p>



<a name="160883253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160883253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160883253">(Mar 15 2019 at 15:07)</a>:</h4>
<p>The MIR for the function is stored in a side table in the <code>TyCtxt</code> which is accessed by <code>DefId</code>. The query you're probably most interested in is <code>tcx.mir_const()</code> <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.mir_const" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.mir_const">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ty/struct.TyCtxt.html#method.mir_const</a></p>



<a name="160885410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160885410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160885410">(Mar 15 2019 at 15:32)</a>:</h4>
<p>Const eval actually uses the <code>optimized_mir</code> query. <code>mir_const</code> is only for const qualification</p>



<a name="160886369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160886369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160886369">(Mar 15 2019 at 15:42)</a>:</h4>
<p>Oops. Thanks <span class="user-mention" data-user-id="124288">@oli</span></p>



<a name="160961335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/Which%20kind%20of%20operands%20functions%20are%3F/near/160961335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Poveda <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/Which.20kind.20of.20operands.20functions.20are.3F.html#160961335">(Mar 16 2019 at 18:11)</a>:</h4>
<p>Ok now I've got weekend reading material, thank you :D</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>